---
#==============================================================#
# File      :   datasource.yml
# Mtime     :   2025-05-25
# Desc      :   Grafana Data Source Provisioner Definition
# Path      :  /etc/grafana/provisioning/datasources/pigsty.yml
# License   :   AGPLv3 @ https://doc.pgsty.com/about/license
# Copyright :   2018-2025  Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#

apiVersion: 1

# remove provisioned data sources
deleteDatasources:
  - { name: Prometheus , orgId: 1 }
  - { name: Meta       , orgId: 1 }
  - { name: Loki       , orgId: 1 }
  - { name: Static     , orgId: 1 }

# install following data sources
datasources:

  # Pigsty Monitor Database (Prometheus)
  - name: Prometheus
    uid: ds-prometheus
    type: prometheus
    url: http://127.0.0.1:9090
    access: proxy
    isDefault: true
    editable: true
    version: 1
    jsonData:
      timeInterval: "2s"
      queryTimeout: "60s"
      tlsAuth: false
      tlsAuthWithCACert: false
    secureJsonData: {}

  # Pigsty Meta Database (PostgreSQL)
  - name: Meta
    type: postgres
    uid: ds-meta
    url: 127.0.0.1:5432
    access: proxy
    user: dbuser_view
    database: meta
    editable: true
    jsonData: {
      "database": "meta",
      "connMaxLifetime": 14400,
      "maxIdleConns": 10,
      "maxOpenConns": 64,
      "postgresVersion": {% if pg_version is defined %}{% if pg_version|int >= 15 %}15{% else %}{{ pg_version }}{% endif %}{% else %}10{% endif %}00,
      "sslmode": "require",
      "tlsAuth": false,
      "tlsAuthWithCACert": false
    }
    secureJsonData:
      password: DBUser.Viewer

  # Pigsty Logging Database (Loki)
  - name: Loki
    type: loki
    uid: ds-loki
    url: http://127.0.0.1:3100
    access: proxy
    editable: true

  # Pigsty Static Datasource
  - name: Static
    type: marcusolsson-static-datasource
    uid: ds-static
    editable: true

...